clear all
use "Monadic example file.dta", replace


*** Note: In the two following examples, the created spatial effect variable has no values for country_i=="Japan"
*** since Japan has no contiguous neighbor in this dataset


* Create spatial lag variable with (undirected) contiguity variable as connectivity variable
spmon  tax_k, weight(contig_or_less1000km) i(country_i) k(country_k) time(year) sename(SL_monadic_W_contig) filename(SL_monadic_W_contig)


* As above, but not row-standardized
spmon  tax_k, weight(contig_or_less1000km) i(country_i) k(country_k) time(year) sename(SL_monadic_W_contig_norowst) filename(SL_monadic_W_contig_norowst) norowst

* Create spatial lag variable with directed exports as connectivity variable
spmon  tax_k, weight(exports_i_to_k) i(country_i) k(country_k) time(year) sename(SL_monadic_W_exports_i_to_k) filename(SL_monadic_W_exports_i_to_k)


*** Note: In the following example, directed exports from i to k are reverted to create a SL variable with exports from k to i as connectivity variable
* Create spatial lag variable with reverted directed exports as connectivity variable
spmon  tax_k, weight(exports_i_to_k) i(country_i) k(country_k) time(year) sename(SL_monadic_W_exports_k_to_i) filename(SL_monadic_W_exports_k_to_i) reverse_W
